//
//  EnumModel.swift
//  mySwift
//
//  Created by X-MEN on 2021/12/6.
//

import Foundation

/*
 - =左边的值是枚举值，例如 MON
 - =右边的值在swift中称为 RawValue（原始值），例如 "MON"
 - 两者的关系为：case 枚举值 = rawValue原始值
 -只需要对应的枚举遵守该协议即可，然后通过allCases获取所有枚举值
 */
enum Week: String,CaseIterable {
    case MON = "MON"
    case TUE = "TUE"
    case WED = "WED"
    case THU = "THU"
    case FRI = "FRI"
    case SAT = "SAT"
    case SUN = "SUN"
    case NONE = "NONE"
    
    func getCode() -> String {
        switch self {
        case .MON:
            return "mon"
        case .TUE:
            return "m"
        case .WED:
            return "m"
        case .THU:
            return "m"
        case .FRI:
            return "m"
        case .SAT:
            return "m"
        case .SUN:
            return "m"
        case .NONE:
            return "m"
        }
    }
    
}


extension Week {
    //计算属性
    var currentCode: String {
        switch self {
        case .MON:
            return "月"
        case .TUE:
            return ""
        case .WED:
            return ""
        case .THU:
            return ""
        case .FRI:
            return ""
        case .SAT:
            return ""
        case .SUN:
            return ""
        default :
            return ""
        }
    }
}

//<!--2、通过for循环遍历-->
//var allCase = Week.allCases
//for c in allCase{
//    print(c)
//}
//
//<!--3、通过函数式编程遍历-->
//let allCase = Week.allCases.map({"\($0)"}).joined(separator: ", ")
//print(allCase)
////******打印结果******
//MON, TUE, WED, THU, FRI, SAT, SUN

enum CombineDirect{
    //枚举中嵌套的枚举
    enum BaseDirect{
        case up
        case down
        case left
        case right
    }
    //通过内部枚举组合的枚举值
    case leftUp(baseDIrect1: BaseDirect, baseDirect2: BaseDirect)
    case leftDown(baseDIrect1: BaseDirect, baseDirect2: BaseDirect)
    case rightUp(baseDIrect1: BaseDirect, baseDirect2: BaseDirect)
    case rightDown(baseDIrect1: BaseDirect, baseDirect2: BaseDirect)
}

//使用
let leftUp = CombineDirect.leftUp(baseDIrect1: CombineDirect.BaseDirect.left, baseDirect2: CombineDirect.BaseDirect.up)


struct Locale {
    let language: String
    let country: String
}

struct LanguageInfo {
    let languageName: String
    let locale: Locale
    let languageId: Int
    let desc: String
}

enum LanguageType {
    case zh
    case en
    case id
    case hi
    case bn
    case pt
    case ur
    case ms
    case fr
    case de
    case ko
    case vi

    var info: LanguageInfo {
        switch self {
        case .zh:
            return LanguageInfo(languageName: "简体中文", locale: Locale(language: "zh", country: "CN"), languageId: 0, desc: "zh_cn")
        case .en:
            return LanguageInfo(languageName: "English", locale: Locale(language: "en", country: "US"), languageId: 1, desc: "en_us")
        case .id:
            return LanguageInfo(languageName: "Bahasa Indonesia", locale: Locale(language: "id", country: "ID"), languageId: 2, desc: "id_id")
        case .hi:
            return LanguageInfo(languageName: "हिंदी", locale: Locale(language: "hi", country: "IN"), languageId: 3, desc: "hi_in")
        case .bn:
            return LanguageInfo(languageName: "বাঙালি", locale: Locale(language: "bn", country: "BD"), languageId: 4, desc: "bn_bd")
        case .pt:
            return LanguageInfo(languageName: "Português", locale: Locale(language: "pt", country: "PT"), languageId: 5, desc: "pt_pt")
        case .ur:
            return LanguageInfo(languageName: "اردو", locale: Locale(language: "ur", country: "PK"), languageId: 6, desc: "ur_pk")
        case .ms:
            return LanguageInfo(languageName: "Melayu", locale: Locale(language: "ms", country: "MY"), languageId: 7, desc: "ms_my")
        case .fr:
            return LanguageInfo(languageName: "Français", locale: Locale(language: "fr", country: "FR"), languageId: 8, desc: "fr_fr")
        case .de:
            return LanguageInfo(languageName: "Deutsch", locale: Locale(language: "de", country: "DE"), languageId: 9, desc: "de_de")
        case .ko:
            return LanguageInfo(languageName: "한국어", locale: Locale(language: "ko", country: "KR"), languageId: 10, desc: "ko_kr")
        case .vi:
            return LanguageInfo(languageName: "Tiếng Việt", locale: Locale(language: "vi", country: "VN"), languageId: 11, desc: "vi_vn")
        }
    }
}
